/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PainelEnsalamento.java
 *
 * Created on 03/12/2011, 11:03:52
 */
package projetointegrado;

import java.util.ArrayList;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Emerson
 */
public class PainelEnsalamento extends javax.swing.JPanel {
public ArrayList<Materia> arrayMaterias = new ArrayList<Materia>();
    /** Creates new form PainelEnsalamento */
    public PainelEnsalamento() {
        initComponents();
        DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel();
        arrayMaterias = ProjetoIntegrado.player.getmaterias();
        String[][] dados = new String[arrayMaterias.size()][6];
        jTable1.setModel(modelo);
        dados[1][0] = arrayMaterias.get(0).getCodigoMateria();
        for(int i = 0; i < arrayMaterias.size(); i++){
            if(arrayMaterias.get(i).getStatus() == 2){
            for(int j = 0; j < arrayMaterias.get(i).getDia().length; j++){
                if(arrayMaterias.get(i).getDia()[j].equals("Segunda")){
                    dados[i][0] = arrayMaterias.get(i).getCodigoMateria() + "-" + arrayMaterias.get(i).getBloco() + "-" + arrayMaterias.get(i).getSala();
                }
                if(arrayMaterias.get(i).getDia()[j].equals("Terça")){
                    dados[i][1] = arrayMaterias.get(i).getCodigoMateria() + "-" + arrayMaterias.get(i).getBloco() + "-" + arrayMaterias.get(i).getSala();
                }
                if(arrayMaterias.get(i).getDia()[j].equals("Quarta")){
                    dados[i][2] = arrayMaterias.get(i).getCodigoMateria() + "-" + arrayMaterias.get(i).getBloco() + "-" + arrayMaterias.get(i).getSala();
                }
                if(arrayMaterias.get(i).getDia()[j].equals("Quinta")){
                    dados[i][3] = arrayMaterias.get(i).getCodigoMateria() + "-" + arrayMaterias.get(i).getBloco() + "-" + arrayMaterias.get(i).getSala();
                }
                if(arrayMaterias.get(i).getDia()[j].equals("Sexta")){
                    dados[i][4] = arrayMaterias.get(i).getCodigoMateria() + "-" + arrayMaterias.get(i).getBloco() + "-" + arrayMaterias.get(i).getSala();
                }
            }
            
        }
        }
        for(int i = 0; i < arrayMaterias.size(); i++){
            if(arrayMaterias.get(i).getStatus()==2){
        modelo.addRow(new Object[]{dados[i][0],dados[i][1],dados[i][2],dados[i][3],dados[i][4],});
            }
        }

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();

        setPreferredSize(new java.awt.Dimension(830, 600));

        jLabel1.setFont(new java.awt.Font("Tahoma", 3, 24)); // NOI18N
        jLabel1.setText("Ensalamento");

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sabado"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jTable1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(330, 330, 330))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 810, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 318, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(207, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    // End of variables declaration//GEN-END:variables
}
